package com.example.springcloud.config;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author :lihao
 * @date :2020/11/27
 * @description : 配置文件
 */
@Configuration
public class ConfigBean {

    /**
     * 配置负载均衡实现RestTemplate
     * 添加@LoadBalanced
     * 基于Ribbon
     */
    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }
}
